package com.mkvld.appietijdenv2;

import com.mkvld.appietijdenv2.R;
import com.mkvld.appietijdenv2.data.Preferences;
import com.mkvld.appietijdenv2.fragments.FragExtrasKPTV9;
import com.mkvld.appietijdenv2.fragments.FragExtrasV9;
import com.mkvld.appietijdenv2.fragments.FragPayrollKPTV9;
import com.mkvld.appietijdenv2.fragments.FragPayrollV9;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

public class FragPeriodTablet extends Fragment {
	FragShiftsV14 fragShifts;
	FragPayrollV9 fragPayroll;
	FragExtrasV9 fragExtras;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		fragShifts = new FragShiftsV14();
		fragShifts.setArguments(getArguments());
		
		if (Preferences.getContract(getActivity()) > 48) {
			fragPayroll = new FragPayrollV9();
			fragExtras = new FragExtrasV9();
		} else {
			fragPayroll = new FragPayrollKPTV9();
			fragExtras = new FragExtrasKPTV9();
		} 
		fragPayroll.setArguments(getArguments());
		fragExtras.setArguments(getArguments());
	}
	
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		return inflater.inflate(R.layout.frag_period, null, false);
	}
	
	@Override
	public void onViewCreated(View view, Bundle savedInstanceState) {
		super.onViewCreated(view, savedInstanceState);
		getFragmentManager().beginTransaction()
			.replace(R.id.am_shifts, fragShifts)
			.replace(R.id.am_payroll, fragPayroll)
			.replace(R.id.am_extras, fragExtras)
			.commit();
	}

	public void update() {
		fragShifts.update();
		fragPayroll.update();
		fragExtras.update();
	}
	
	
}
